package com.lvmama.java.rhino.spark.hdfs;

import java.io.IOException;

import org.apache.hadoop.fs.FSDataOutputStream;

import com.lvmama.java.rhino.spark.core.hdfs.HdfsHelper;
import com.lvmama.java.rhino.spark.tables.LogDetail;
import com.lvmama.java.rhino.spark.utils.Constants;

public class LogDetailHdfsHelper extends HdfsHelper {

	private static final long serialVersionUID = 5446534526663484238L;
	public static final String TABLE_NAME = "LOG_DETAIL";
	@Override
	public void save(FSDataOutputStream outputStream, Object obj) {
		if(!(obj instanceof LogDetail)) {
			return;
		}
		LogDetail entity = (LogDetail)obj;
		String entityStr = entity.toLogStr(Constants.SEPERATOR);
		try {
			outputStream.writeUTF(entityStr);
			outputStream.flush();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Override
	protected String getTableName() {
		return TABLE_NAME;
	}

}
